<?php
namespace app\model;
use think\model;

class UserInfoHobby extends Model{

    protected $table = "user_info_liketag";



    public function saveHobby($data,$uid){
        foreach ($data as $key=>$value){
            $infoIdentity = new UserInfoHobby();
            $infoIdentity->updateHobby($uid,$key,$value);
        }
    }

    public function updateHobby($uid,$hobby,$flag){

        if (!$flag){
            UserInfoHobby::update([
                "$hobby"=>" "
            ],[
                'id'=>"$uid"
            ]);
        }else{
            UserInfoHobby::update([
                "$hobby"=>$hobby
            ],[
                'id'=>"$uid"
            ]);
        }

    }


    function queryHobby($id){
        $hobby = UserInfoHobby::where('id',$id)->select();
        $rs = $hobby->toArray();
        return $rs;
    }

    function insertHb($uid){
        UserInfoHobby::create([
            'id'=>$uid,
        ]);
    }
}